/*
 * Copyright 2010 Mttang.com All right reserved. This software is the confidential and proprietary information of
 * Mttang.com ("Confidential Information"). You shall not disclose such Confidential Information and shall use it only
 * in accordance with the terms of the license agreement you entered into with Mttang.com.
 */
package com.mttang.sys.web.validation;

import java.util.HashMap;
import java.util.Map;
import org.springframework.beans.factory.BeanFactory;

/**
 * 实现数据的验证 类SysValidation.java的实现描述：TODO 类实现描述
 * 
 * @author 郑斌 2010-6-21 上午09:03:05
 */
public class SysValidation {

    private static void validateNullAndLength(String fieldName, String aFieldValue, 
                        boolean isAllowNull, int length,Map<Object, Object> errorInfoMap) {
        // 是否允许为null
        StringBuilder strBuilder = new StringBuilder();
        if (!isAllowNull) {
            if (aFieldValue == null || "".equals(aFieldValue)) {
                strBuilder.append("null");
            }
        }

        if (aFieldValue != null && aFieldValue.length() > length) {
            if (strBuilder.length() > 0) {
                strBuilder.append(";").append("too long");
            } else {
                strBuilder.append("too  long");
            }
        }

        if (strBuilder.length() > 0) {
            errorInfoMap.put(fieldName, strBuilder.toString());
        }

    }
    public static Map<Object, Object>  isValidateUser (Map<Object, Object> aMap) {
        
        Map<Object, Object> errorInfoMap = new HashMap<Object, Object>();
        
        String pattern = "";
        if(aMap.containsKey("GAMEID")){//游戏ID
            String gameID = (String)aMap.get("GAMEID");
            
            if(gameID == null || "".equals(gameID)){
                errorInfoMap.put("GAMEID", "null");
            }
            //特殊字符的判断
            pattern = "^([0-9])*$";
            if (gameID != null && !gameID.matches(pattern)){
            }
            
             }
        return errorInfoMap;
        }
    

}
